package com.taptech.doufu.ui.viewholder.albums;

import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.taptech.doufu.R;
import com.taptech.doufu.ui.activity.MoreAlbumsActivity;
import com.taptech.doufu.bean.AlbumsBean;
import com.taptech.doufu.util.ImageManager;
import com.taptech.doufu.util.StartActivityUtil;

/**
 * Created by lsy on 2015/6/29.
 */

public class MoreAlbumsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener
{
    Context mContext;
    /**
     * UI控件
     */
    protected View mSubjectLayout;
    protected SimpleDraweeView mSubjectImageView;
    protected TextView mSubjectDescribtionView;

    /**
     * 数据
     */
    protected AlbumsBean contentBean;
    protected Handler mHandler;
    protected int mPositon;

    public MoreAlbumsViewHolder(View itemView, Context context)
    {

        super(itemView);
        mContext = context;
        mSubjectLayout = (View) itemView.findViewById(R.id.subject_layout);
        mSubjectImageView = (SimpleDraweeView) itemView.findViewById(R.id.subject_imageview);
        mSubjectDescribtionView = (TextView) itemView.findViewById(R.id.subject_describtion);
        mSubjectLayout.setOnClickListener(this);
    }


    public void setChildContent(AlbumsBean bean, int position)
    {

        contentBean = bean;
        if (bean == null)
        {
            return;
        }
        mPositon = position;

        if (bean.getIcon() != null || bean.getCover() != null)
        {
            mSubjectImageView.setBackgroundColor(Color.WHITE);
            ImageManager.loadImage(mSubjectImageView, MoreAlbumsActivity.type == MoreAlbumsActivity.HOT_ALBMUS ? bean.getIcon() : bean.getCover(), MoreAlbumsActivity.type == MoreAlbumsActivity.HOT_ALBMUS ? 2.0f : 1.0f);
            // ImageManager.displayImage(mSubjectImageView,bean.getIcon());
        }
        if (bean.getName() != null)
        {
            mSubjectDescribtionView.setText(bean.getName());
        }

    }

    public void setHandler(Handler handler)
    {
        mHandler = handler;
    }

    @Override
    public void onClick(View view)
    {

        switch (view.getId())
        {
            case R.id.subject_layout:
                StartActivityUtil.albumsOnclick(mContext, contentBean);
                break;
        }
    }

    @Override
    public boolean onLongClick(View view)
    {

        return true;
    }


}
